package com.yksj.healthtalk.adapter;
import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yksj.healthtalk.ui.R;

/**
 * 沙龙类型
 * @author Administrator
 *
 */
public class salonInfoTypeAdapter extends BaseAdapter{
	private List<String> strs;
	private Context context;
	private LayoutInflater inflater;
	private Boolean  isAddBtnVisable = false;
	
	public salonInfoTypeAdapter(Context context, List<String> strs){
		if (strs == null) {
			strs = new ArrayList<String>();
		}
		this.strs = strs;	
		this.context = context;
		inflater = LayoutInflater.from(context);
	}
	
	@Override
	public int getCount() {
		
		if (isAddBtnVisable) {
			return strs.size()+1;
		}
		return strs.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}
	
	public void setAddBtnVisable(Boolean b){
		this.isAddBtnVisable = b;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder;
		if (convertView == null || convertView.getTag() == null) {
			viewHolder = new ViewHolder();
			convertView = inflater.inflate(R.layout.salon_info_type_item, null);
			viewHolder.typeName = (TextView) convertView.findViewById(R.id.info_type);
			convertView.setTag(viewHolder);
		}else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		
		if (position == strs.size()&&isAddBtnVisable) {
			viewHolder.typeName.setText("+");
		}else {
			viewHolder.typeName.setText(strs.get(position));
		}
		
		return convertView;
	}
	
	class ViewHolder{
		private TextView typeName;
	}

}
